package com.songcy.dao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.dao.BaseDao;

public class GetRepeatNamesDao extends BaseDao{
	public List getRepeatNames() throws SQLException
	{
		String sql = "select distinct firstname from info where" +
				" firstname in (select firstname from info" +
				" group by firstname having count(firstname) > 1)";
		super.getConnection();
		super.stmt= super.conn.prepareStatement(sql,
				ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
		ResultSet rs = stmt.executeQuery();
		return this.fetchMultiResults(rs,null);
	}

	@Override
	protected List fetchMultiResults(ResultSet rs, Object clas)
			throws SQLException {
		List strings = new ArrayList();
		while(rs.next())
		{
			//System.out.print(rs.getString(1));
			strings.add(rs.getString(1));
		}
		// TODO Auto-generated method stub
		return strings;
	}
}
